function openEditFileTypeWindow() {
    var fileTypeEditWindow = Ext.create('Ext.window.Window', {
        title: "增加类型",
        iconCls:'x-fa fa-flag',
        width: 350,
        modal:true,
        items:[
            {
                xtype:'form',
                width:'100%',
                height:'100%',
                border:false,
                margin: '5 0 0 0',

                items:[
                    {
                        xtype: 'textfield',
                        id:'fileTypeCnName',
                        labelAlign:'right',
                        allowBlank:false,
                        fieldLabel:'类型名称'
                    }
                ],
                buttons: [
                    {
                        xtype: 'button',
                        text: '取消',
                        handler: function() {
                             fileTypeEditWindow.close()
                        }
                    },
                    {
                         xtype: 'button',
                         formBind:true,
                         text: '确定',
                         handler: function() {

                            Ext.Ajax.request({
                                url: "../filetype/save",
                                params: {
                                   cnName:Ext.getCmp("fileTypeCnName").getValue(),
                                },
                                success:function(response, opts) {
                                    fileTypeEditWindow.close()
                                    fileTypeStore.load()
                                }
                            })

                           
                         }
                    }
                ]
            }
        ]
    })
    fileTypeEditWindow.show()
}



var fileTypeStore = Ext.create('Ext.data.Store', {
    autoLoad: true,
    pageSize: 1000,
    remoteSort: true,
    remoteFilter:true,
    //sorters: [{property:"a.id",direction:"DESC"}],
    listeners:{
        beforeload:function() {
            
        }
    },
    proxy: {
        type: 'ajax',
        url : '../filetype/store',
        reader: {
            type: 'json',
            root: 'results',
            totalProperty: 'total'
        }
    }
});

var fileType = Ext.create('Ext.grid.Panel', {
    title: '',
    store: fileTypeStore,
    listeners:{
        select:function(obj, record, index, eOpts){
            Ext.getCmp('btnDelFileType').enable()
        }
                               
    },
    columns: [
        { text: '类型名称', dataIndex: 'cnName',width:200 },
        { 
            text: '创建时间', dataIndex: 'dateCreated',
            flex:1 ,
            xtype: 'datecolumn',
            format: 'Y-m-d H:i:s',
        }
    ],
    height: 600,
    width: 894
});

var fileTypeWindow = Ext.create('Ext.window.Window', {
    title: '类型列表',
    //iconCls:'x-fa fa-database',
    height: 600,
    width: 900,
    //layout: 'fit',
    modal:true,
    closeAction:'hide',
    layout: 'border',
    defaults: {
        collapsible: false,
        split: true,
        bodyPadding: 0
    },
    listeners:{
      close:function() {
          window.location='index'
      }
    },
    tbar: [
        { 
            xtype: 'button', text: '增加',iconCls:'x-fa fa-plus',
            handler:function() {
                openEditFileTypeWindow()
            } 
        },
        { 
            xtype: 'button', text: '删除',iconCls:'x-fa fa-minus',id:'btnDelFileType',disabled:true,
            handler:function() {
                var selection = fileType.getSelection()
                var id = selection[0].data.id
                Ext.Ajax.request({
                    url: "../filetype/delete",
                    params: {id:id},
                    success:function(response, opts) {
                        fileTypeStore.load()
                        Ext.getCmp('btnDelFileType').disable()




                    }
                })

                /*
                if (selection.length==0) {
                    alert("请选择要删除的类型!")
                } else {
                    
                }*/
                
               
            } 
        },
    ],
    items:[
        fileType
    ]
})